package com.bw.study;

import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.study.databinding.ItemViewBinding;

import java.util.List;

public class RvAdapter extends RecyclerView.Adapter<RvAdapter.RvVH>{

    private List<String>list;

    public RvAdapter(List<String>list){
        this.list = list;
    }

    @NonNull
    @Override
    public RvVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new RvVH(ItemViewBinding.inflate(LayoutInflater.from(parent.getContext())));
    }

    @Override
    public void onBindViewHolder(@NonNull RvVH holder, int position) {
        holder.viewBinding.itemTv.setText(list.get(position));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class RvVH extends RecyclerView.ViewHolder {

        ItemViewBinding viewBinding;
        public RvVH(ItemViewBinding viewBinding) {
            super(viewBinding.getRoot());
            this.viewBinding = viewBinding;
        }
    }

}
